package com.feng.zhihao.apigeteway.gateway.bean.impl.GENERATION_RULE;

import org.springframework.stereotype.Component;

import com.feng.zhihao.apigeteway.entity.InterfaceFieldGenerationRule;
import com.feng.zhihao.apigeteway.entity.InterfaceFieldInfo;
import com.feng.zhihao.apigeteway.gateway.ReqContext;
import com.feng.zhihao.apigeteway.gateway.bean.GENERATION_RULE;
import com.xiaoleilu.hutool.util.RandomUtil;

@Component("GENERATION_RULE_ENUM_RANDOM")
public class GENERATION_RULE_ENUM_RANDOM implements GENERATION_RULE {

	@Override
	public Object generationValue(InterfaceFieldInfo interfaceFieldInfo,InterfaceFieldGenerationRule rule, ReqContext reqContext) {
		String[] enumRandom=rule.getEnumRandom().split("@fzh@");
		return enumRandom[RandomUtil.randomInt(enumRandom.length)];
	}
}
